package com.example.pc.updata.DaTi;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.example.pc.http.API;
import com.example.pc.http.Okhttp;
import com.example.pc.updata.Baes.BaseActivity;
import com.example.pc.updata.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 答復
 */
public class DaFuActivity extends BaseActivity {


    @BindView(R.id.dt_content)
    EditText dtContent;
    @BindView(R.id.btn_sub)
    Button btnSub;
    String titel;
    String content;
    String id;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_dafu);
        ButterKnife.bind(this);
        id = getIntent().getStringExtra("id");

        btnSub.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                content = dtContent.getText().toString();

                if (content.equals("")) {
                    showMessage("内容不许为空！");
                    return;
                }
                sub();
//                showMessage("反馈成功！");
            }


        });
    }

    private void sub() {
        API.addjianyi(DaFuActivity.this, id, content, new Okhttp.Objectcallback() {
            @Override
            public void onsuccess(String st) {
                Toast.makeText(DaFuActivity.this, "添加回复成功！", Toast.LENGTH_SHORT).show();
                finish();
            }

            @Override
            public void onFalia(int code, String errst) {
                Toast.makeText(DaFuActivity.this, "网络错误" + errst, Toast.LENGTH_SHORT).show();
            }
        });

    }
}
